﻿using Iesi.Collections.Generic;

namespace CxRomos.Core.Domain.Entities {
    public class Permission {
        private ISet<AccountPermission> _accountPermissions;

        public Permission() {
            _accountPermissions = new HashedSet<AccountPermission>();
        }

        public virtual int PermissionId { get; set; }
        public virtual string Name { get; set; }
        public virtual ISet<AccountPermission> AccountPermissions {
            get { return _accountPermissions; }
            set { _accountPermissions = value; }
        }

        public override int GetHashCode() {
            int toReturn = base.GetHashCode();
            toReturn ^= PermissionId.GetHashCode();
            return toReturn;
        }

        public override bool Equals(object obj) {
            if (obj == null) {
                return false;
            }
            var toCompareWith = obj as Permission;
            return toCompareWith == null ? false : ((PermissionId == toCompareWith.PermissionId));
        }
    }
}